package com.xcity.game.adventure.model;

import java.util.Date;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 仇人
 * @author yang.li
 *
 */
public class Foe {
	
	@JSONField(name = "0")
	protected long id; // 玩家id
	@JSONField(name = "1")
	protected byte cause; // 成为仇人的原因
	@JSONField(name = "2")
	protected int type; // 类型:获得的物品id(为0表示获取的现金)
	@JSONField(name = "3")
	protected int count; // type=0时表示现金数量,type=物品id时表示物品数量
	@JSONField(name = "4")
	protected Date time; // 成为仇人的时间
	
	public static final byte CAUSE_STEAL = 0, CAUSE_ATTACK = 1, CAUSE_RANDOM = 2/*随机出的目标*/;
	
	public Foe() {}
	
	public Foe(long id, int itemId, int count) {
		this(id, CAUSE_ATTACK, itemId, count);
	}
	
	public Foe(long id, long gold) {
		this(id, CAUSE_STEAL, CAUSE_STEAL, gold > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) gold);
	}
	
	private Foe(long id, byte cause, int type, int count) {
		this.id = id;
		this.cause = cause;
		this.type = type;
		this.count = count;
		this.time = new Date();
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public byte getCause() {
		return cause;
	}

	public void setCause(byte cause) {
		this.cause = cause;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

}
